package sctu.edu.java.year2016.team06.luoxin.day20160610.chapter17_1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created by Administrator on 2016/6/13.
 */
public class Delete {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection ct;
            try {
                ct = DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "hequnjie");
                Statement st=ct.createStatement();
/*按条件删除表格中的数据
 * delete from student1 where id>=2;
 * 删除表格中所有数据，保留表格结构
 * delete from student1;
 * 删除表格
 * drop table student1;
 * */
                String sqlstr=" delete from student1 where age>=20;";
                st.executeUpdate(sqlstr);
                System.out.println("删除成功");
            } catch (SQLException e) {
// TODO Auto-generated catch block
                e.printStackTrace();
            }
        } catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
            e.printStackTrace();
        }


    }

}
